package com.moyun.common.component;

import org.aopalliance.intercept.MethodInterceptor;

import org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor;
import org.springframework.stereotype.Component;
import javax.validation.constraints.NotNull;
import java.lang.reflect.Method;

/**
 * @author : ybx
 * @description: 自定义的一个StaticMethodMatcherPointcutAdvisor 类去学习
 * @date : 2022-03-24 18:43:11
 **/
@Component
public class MyselfDefinedOneStaticMethodMatcherPointcutAdvisor extends StaticMethodMatcherPointcutAdvisor {
    private static final long serialVersionUID = 1008446227962291598L;

    @Override
    public boolean matches(Method method, @NotNull Class<?> targetClass) {
        // 这里是描述你要对哪个方法做增强，匹配到之后就会走自己定义的通知
        return "com.copyrightagency.middleservice.customerservice.controller.back.BackStandardFeeController.getWorkDays".equals(method.getDeclaringClass().getName() + "." + method.getName());
    }


    public MyselfDefinedOneStaticMethodMatcherPointcutAdvisor() {
        setAdvice((MethodInterceptor)(MethodInvocation) ->{
            System.out.println("-------->这是增强的通知");
            return MethodInvocation.proceed();
        });

    }
}
